﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MessageRouter.Configuration
{
    sealed class ConfigurationManager
    {
        private static readonly ConfigurationManager instance = new ConfigurationManager();

        private readonly RouterModelConfigurationSection configuration;

        private ConfigurationManager()
        {
            this.configuration = (RouterModelConfigurationSection)System.Configuration.ConfigurationManager.GetSection("routerModel");
        }

        public static ConfigurationManager Current
        {
            get { return instance; }
        }

        public IEnumerable<ReaderConfigurationElement> Readers
        {
            get { return this.configuration.Readers.OfType<ReaderConfigurationElement>().ToArray(); }
        }

        public IEnumerable<WriterConfigurationElement> Writers
        {
            get { return this.configuration.Writers.OfType<WriterConfigurationElement>().ToArray(); }
        }

        public IEnumerable<BindingConfigurationElement> Subscriptions
        {
            get { return this.configuration.Bindings.OfType<BindingConfigurationElement>().ToArray(); }
        }
    }
}
